package pers.fjl.test.controller;

import com.auth0.jwt.exceptions.JWTVerificationException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import pers.fjl.common.constant.MessageConstant;
import pers.fjl.common.entity.Result;

import javax.validation.ConstraintViolationException;

@Slf4j
@ControllerAdvice
@Api(value = "全局异常处理模块", description = "全局异常处理的接口信息")
public class BaseExceptionHandler {
//    @ExceptionHandler(Exception.class)
//    @ResponseBody
//    public Result handler(Exception e) {
//       if (e instanceof RuntimeException){
//           return new Result(false, MessageConstant.ERROR, e.getMessage());
//        }
//        System.out.println("处理异常");
//        return new Result(false, MessageConstant.ERROR, e.getMessage());
//    }
//
//    @ExceptionHandler(value = {RuntimeException.class})
//    public Result runtimeHandler(RuntimeException e) {
//        System.out.println("出现异常："+e.getMessage());
//        return new Result(false, MessageConstant.LOGINERROR, e.getMessage());
//    }
//
//    @ExceptionHandler(value = {JWTVerificationException.class})
//    public Result jwtHandler(JWTVerificationException e) {
//        log.debug(e.getMessage());
//        return new Result(false, MessageConstant.ACCESSERROR, e.getMessage());
//    }
//
//    @ExceptionHandler(value = {ConstraintViolationException.class})
//    @ResponseBody
//    public Result validHandle(ConstraintViolationException e) {
//        return new Result(false, MessageConstant.ERROR, e.getMessage());
//    }
}
